package com.mall.admin.service;


import com.mall.commons.utils.R;
import com.mall.domain.SmsHomeNewProduct;
import com.mall.interface1.api.SmsHomeNewProductServiceApi;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class SmsHomeNewProductService  {

    @DubboReference
    SmsHomeNewProductServiceApi smsHomeNewProductServiceApi;

    public R findByPage(Integer pageNum, Integer pageSize, String productName, Integer recommendStatus) {
        return R.success(smsHomeNewProductServiceApi.findByPage(pageNum,pageSize,productName,recommendStatus));
    }

    public R updateRecommendStatus(List<Long> ids, Integer recommendStatus) {
        for (Long id : ids) {
            smsHomeNewProductServiceApi.updateRecommendStatus(id, recommendStatus);
        }
        return R.success("修改成功");
    }

    public R updateSort(Long id, Integer sort) {
        return R.success(smsHomeNewProductServiceApi.updateSort(id,sort));
    }

    public R delete(List<Long> ids) {
        for (Long id : ids) {
            smsHomeNewProductServiceApi.delete(id);
        }
        return R.success("删除成功");
    }

    public R addCreate(List<SmsHomeNewProduct> homeNewProductList) {
        for (SmsHomeNewProduct smsHomeNewProduct : homeNewProductList) {
            smsHomeNewProductServiceApi.addCreate(smsHomeNewProduct);
        }
        return R.success("添加成功");
    }
}
